package com.shengtsource.mvc.pojo;

import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Pattern;

/**
 * 处理器实体
 * @author shengtsource
 */
public class Handler {
    /**
     * 规则匹配，主要定义URL
     */
    private Pattern pattern;
    /**
     * 具体hander调用的方法
     */
    private Method method;
    /**
     * 调用目标对象
     */
    private Object targetObject;
    /**
     * 参数名称与参数索引位置的集合
     */
    private Map<String,Integer> parameterIndexMapping;
    /**
     * 允许访问当前Handler用户名集合
     */
    private List<String> permissionUser;

    public Handler(Pattern pattern, Method method, Object targetObject) {
        this.pattern = pattern;
        this.method = method;
        this.targetObject = targetObject;
        this.parameterIndexMapping = new HashMap<>();
        this.permissionUser = new ArrayList<>();
    }

    public Pattern getPattern() {
        return pattern;
    }

    public void setPattern(Pattern pattern) {
        this.pattern = pattern;
    }

    public Method getMethod() {
        return method;
    }

    public void setMethod(Method method) {
        this.method = method;
    }

    public Object getTargetObject() {
        return targetObject;
    }

    public void setTargetObject(Object targetObject) {
        this.targetObject = targetObject;
    }

    public Map<String, Integer> getParameterIndexMapping() {
        return parameterIndexMapping;
    }

    public void setParameterIndexMapping(Map<String, Integer> parameterIndexMapping) {
        this.parameterIndexMapping = parameterIndexMapping;
    }

    public List<String> getPermissionUser() {
        return permissionUser;
    }

    public void setPermissionUser(List<String> permissionUser) {
        this.permissionUser = permissionUser;
    }
}
